#ifndef __SYSTEM_TASK_GARDEN__
#define __SYSTEM_TASK_GARDEN__

#include "at32f421.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
//how to use
// 0-4 add to platform
// 0. add 'include "system_task.c" and include "system_task.h" '
// 1. add 'System_Tick_Counter++;' to system timer handel
// 2. add 'Sys_Task_CheckValid();' at the program beginng after system init, but not nesscessly.(check _SYS_TASK_NEED_CHECKVAILD_)
// 3. add 'Sys_Task_Timer_Scan();' to main loop
// 4. add 'Sys_Task_Process();' to main loop

// after step 4, user can only run step 5 and 6 (in file system_task_user.c)
// 5. add element to SYS_TASK_NUM_ENUM
// 6. add and init element in Sys_Task array

#define GETBIT_VAL(var,bit) 		(var&(1<<bit))
#define SETBIT_VAL(var,bit) 		(var|=(1<<bit))
#define CLRBIT_VAL(var,bit) 		(var&=(~(0x01<<(bit))))

typedef struct{
  void (*Func)(); //must init, task function
  u32 Sys_Task_Time_Count;//must init, delay system tick count
  u32 Sys_Task_Time_Counter;//def 0, how many system tick had gone
}SYS_TASK_PARAM_STRUCT;

//must add to system timer handle
extern volatile u32 System_Tick_Counter;  

//func had better use at the begin of the system, but not nesscessly
//func for check the function point and time count in the task 
void Sys_Task_CheckValid(void);

//timer handle
//calculate the time of system and task , and set the flag of task that time up
void Sys_Task_Timer_Scan(void);

//this function should be in the main loop
//task time's up, it should run task function
void Sys_Task_Process(void);



//////////////////////////////////////////////////////////////////////////////////////////////////////
#endif

